package com.rui.cn.provider.service.system.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.rui.cn.entity.system.SysUser;
import com.rui.cn.provider.repository.system.SysUserDao;
import com.rui.cn.provider.service.system.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 用户 服务实现类
 * </p>
 *
 * @author zhang123
 * @since 2018-01-14
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class SysUserServiceImpl extends ServiceImpl<SysUserDao,SysUser> implements SysUserService{
    @Autowired
    private SysUserDao sysUserDao;

    @Override
    public List<SysUser> selectUserList(Pagination page, Integer state) {
        return  sysUserDao.selectUserList(page, state);
    }

    @Override
    public SysUser selectByUsername(String username) {
        SysUser user=new SysUser();
        user.setUsername(username);
        return sysUserDao.selectOne(user);
    }

    @Override
    public Page<SysUser> userList(Page pagination, String search, String sortBy, String order) {
        return pagination.setRecords(sysUserDao.getUserList(pagination, search,sortBy,order));
    }

    @Override
    public SysUser getUserInfo(Integer id) {
        return sysUserDao.getUserInfo(id);
    }

    @Override
    public int insertMyUser(SysUser user) {
        return sysUserDao.insertMyUser(user);
    }
}
